package priv.conceit.sc.hoxton.file;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import priv.conceit.sc.hoxton.common.web.WebResponse;
import priv.conceit.sc.hoxton.file.config.FileProperties;

@RestController
@RequestMapping("test")
@RefreshScope
public class TestController {

    @Autowired
    FileProperties fileProperties;


    @GetMapping("yml")
    public WebResponse yml(){
        return WebResponse.build(fileProperties);
    }

//    @GetMapping("source/{factory}")
//    public RestfulResponse source(@PathVariable FileSourceEnum factory){
//        LocalFileSourceFactory localFileSourceFactory=new LocalFileSourceFactory();
//        return RestfulResponse.build( localFileSourceFactory.build().preview(null));
//    }

    @Value("${useLocalCache:false}")
    private boolean useLocalCache;

    @RequestMapping("/get")
    public boolean get() {
        return useLocalCache;
    }
}
